import App from './App'

// #ifndef VUE3
import Vue from 'vue'
import './uni.promisify.adaptor'
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
  ...App
})
app.$mount()
// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'
import { createPinia } from 'pinia'
const pinia = createPinia()
export function createApp() {
  const app = createSSRApp(App)
  // 创建全局 Promise，并挂载到 uni 对象上
  let _resolve;
  uni.$onLaunched = new Promise(resolve => {
    _resolve = resolve;
  });
  // 将 resolve 函数挂载到 uni 对象上
  uni.$isResolve = () => {
    uni.$onLaunched.isResolved = true; // 可选：添加状态标记
    _resolve(); // 触发 Promise resolve
  };
  app.use(pinia)
  return {
    app
  }
}
// #endif